<template>
  <header class="header">
    <h1>todos</h1>
    <input id="toggle-all" class="toggle-all" type="checkbox" v-model="selectAll">
    <label for="toggle-all"></label>
    <input
      class="new-todo"
      placeholder="输入任务名称-回车确认"
      autofocus
      @keydown.enter="addtask(settask)"
      v-model="settask"
    />
  </header>
</template>

<script>
// 导入vuex数据 
import {mapState,mapMutations} from 'vuex'
export default {
    name:'TodoHeader',
    data(){
        return {
        }
    },
    computed:{
        ...mapState("todomodule",["selectAll"]),
        selectAll:{
                get(){
                return this.$store.state.todomodule.selectAll
            },
            set(val){
                this.$store.commit('todomodule/setAll',val)
            }
        },
        settask:{
            get(){
                return this.$store.state.todomodule.newtask
            },
            set(val){
                this.$store.commit('todomodule/settask',val)
            }
        }
    },
    methods:{
        ...mapMutations("todomodule",["addtask"])
    }
}
</script>